# -*- coding: utf-8 -*-
# @ Time   :  2020/9/16 14:17
# @ Author : Redtree
# @ File :  code_creator
# @ Desc :  系统不同表模块唯一code生成器


import random
import string
import time


def get_code(key):
    # 统一为六位数，保持长度一致
    TAGS = {
        # 'mp_trial': 'MTRIAL',
        # 'mp_apply_record': 'RECORD',
        'user': 'USERXX',
        'role': 'ROLEXX',
        "dict_type": "DICTYP",
        "dict_data": "DICDAT",
    }
    if TAGS.get(key):
        rd = ''.join(random.sample(f'{string.ascii_letters}{string.digits}', 16))
        ts = str(int(time.time()))
        code = f'{TAGS[key]}{rd}{ts}'
        return code
    else:
        return False
